2020-2021 Sunseeker Telemetry and Lighting System
rtc_a_ex2_countermode.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
58 //******************************************************************************
59 #include "driverlib.h"
60 
61 
62 void main (void)
63 {
64  WDT_A_hold(WDT_A_BASE);
65 
66  //Set P1.0 LED on
68  GPIO_PORT_P1,
69  GPIO_PIN0
70  );
71 
72  //Set P1.0 to output direction
73  GPIO_setAsOutputPin(
74  GPIO_PORT_P1,
75  GPIO_PIN0
76  );
77 
78  //Initialize Counter Mode of RTC_A_A
79  /*
80  * Base Address of the RTC_A_A
81  * Use Prescaler 1 as source for counter
82  * Specify counter as 8 bits, which asserts an interrupt for an overflow
83  */
84  RTC_A_initCounter(RTC_A_BASE,
85  RTC_A_CLOCKSELECT_RT1PS,
86  RTC_A_COUNTERSIZE_8BIT);
87 
88  //Initialize Prescalers
89  /*
90  * Base Address of the RTC_A_A
91  * Specify Initialization of Prescaler 0
92  * Use ACLK as source to prescaler
93  * Divide source by 8 for this prescaler
94  */
95  RTC_A_initCounterPrescale(RTC_A_BASE,
96  RTC_A_PRESCALE_0,
97  RTC_A_PSCLOCKSELECT_ACLK,
98  RTC_A_PSDIVIDER_8);
99 
100  /*
101  * Base Address of the RTC_A_A
102  * Specify Initialization of Prescaler 1
103  * Use Prescaler 0 as source to prescaler
104  * Divide source by 16 for this prescaler
105  */
106  RTC_A_initCounterPrescale(RTC_A_BASE,
107  RTC_A_PRESCALE_1,
108  RTC_A_PSCLOCKSELECT_RT0PS,
109  RTC_A_PSDIVIDER_16);
110 
111  //Enable interrupt for counter overflow
112  RTC_A_clearInterrupt(RTC_A_BASE,
113  RTCTEVIFG);
114  RTC_A_enableInterrupt(RTC_A_BASE,
115  RTCTEVIE);
116 
117  //Start RTC Clock
118  RTC_A_startClock(RTC_A_BASE);
119 
120  __bis_SR_register(LPM3_bits + GIE);
121 }
122 
123 #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
124 #pragma vector=RTC_VECTOR
125 __interrupt
126 #elif defined(__GNUC__)
127 __attribute__((interrupt(RTC_VECTOR)))
128 #endif
129 void RTC_A_ISR (void)
130 {
131  switch (__even_in_range(RTCIV,16)){
132  case 0: break; //No interrupts
133  case 2: break; //RTCRDYIFG
134  case 4: //RTCEVIFG
135  //Toggle P1.0
136  GPIO_toggleOutputOnPin(
137  GPIO_PORT_P1,
138  GPIO_PIN0);
139  break;
140  case 6: break; //RTCAIFG
141  case 8: break; //RT0PSIFG
142  case 10: break; //RT1PSIFG
143  default: break;
144  }
145 }
146 
GPIO_setOutputHighOnPin(GPIO_PORT_LED1|GPIO_PORT_LED2, GPIO_PIN_LED1|GPIO_PIN_LED2)
void main(void)
void RTC_A_ISR(void)